define(function(require, exports, module) {
    "use strict";
    var $ = require("$"),
        tipss = require("dist/tips/init");
    $(window).bind('beforeunload',function(){
			return "";
	});
	$(document).on("click",".js_unbind_beforeunload",function(){
		$(window).unbind('beforeunload');
	});
	$("[data-add-data]").on("click",function(e){
		var $this=$(this),$add=$($this.data("addData")),value=$add.val().trim(),flag=true,len=value.length,
		rmsg=$add.data("msgRequired") || "请填写模板名称！",required=$add.data("ruleRequired"),
		maxlen=$add.data("ruleMaxlength"),mmsg=$add.data("msgMaxlength") || "模板名称最多15个字";
		if(required){
			if (!len) {
				tipss.error(rmsg);
				flag = false;
			}
		}
		if(maxlen&&len){
			if(len>maxlen){
				tipss.error(mmsg);
				flag = false;
			}
		}
		if(flag){
			$this.data("set",$this.closest('form').serializeArray());
		}
		return flag
	});
 });